package org.jeecg.modules.supplier.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.supplier.dto.ProductRelationDto;
import org.jeecg.modules.supplier.entity.PdPurchaseDetail;
import org.jeecg.modules.supplier.mapper.PdPurchaseDetailMapper;
import org.jeecg.modules.supplier.service.PdPurchaseDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 申购订单明细表 服务实现类
 * </p>
 *
 * @author twm
 * @since 2021-06-22
 */
@Service
public class PdPurchaseDetailServiceImpl extends ServiceImpl<PdPurchaseDetailMapper, PdPurchaseDetail> implements PdPurchaseDetailService {


    @Autowired
    private PdPurchaseDetailMapper detailMapper;
    /**
     *
     * 获取详细信息
     * @return
     */
    @Override
    public List<ProductRelationDto> getProduceRelation(String firm, String startDate, String endDate,
                                                       Integer status,String spec, String name, String disStartDate,String disEndDate) {

        List<ProductRelationDto> produceRelation =
                detailMapper.getProduceRelation(firm,startDate, endDate, status, spec, name, disStartDate, disEndDate);

        return produceRelation;
    }

    /**
     * 否配送0未配送，1已经配送
     * @param orderFormId
     * @return
     */
    @Override
    public boolean updataOrderFormStatus(String orderFormId,Integer status) {

        boolean update = this.lambdaUpdate()
                .eq(PdPurchaseDetail::getId, orderFormId)
                .set(PdPurchaseDetail::getStatus, status)
                .set(PdPurchaseDetail::getDeliveryDate,new Date()).update();

        return update;

    }
}
